<?php

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * @property int $id
 * @property int $user_id
 * @property int $pk_user_id
 * @property bool $is_robot
 * @property int $is_win
 * @property int $score
 * @property Carbon $created_at
 */
class ScoreLogs extends Model
{
    /**
     * {@inheritdoc}
     */
    protected $casts = [
        'is_robot' => 'boolean',
    ];

    /**
     * {@inheritdoc}
     */
    public $timestamps = false;

    /**
     * @var null
     */
    public static $userId = null;

    /**
     * {@inheritdoc}
     */
    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        if (static::$userId) {
            $this->table = 'score_logs_' . static::$userId % 10;
        } else {
            $this->table = 'score_logs';
        }
    }
}
